(function() {

    var
    $u = juliet.using({
        i18n : 'juliet.i18n.i18n-0.1',
        uidGenerator : 'juliet.core.uidGenerator-0.1',
        validationResult : 'juliet.validation.validationResult-0.2',
        validationEvent : 'juliet.validation.validationEvent-0.2'
    }),
    ve = $u('validationEvent'),
    vr = $u('validationResult');

    var DEFAULT_EVENTS = ve.CHANGE;

    var BaseClass = function() {

        this.options = null;

        this.uid = null;

        this.chain = null;

        this.validationCache = null;

        this.isSupportedEvent = function(event) {
            var events = (this.options.events || DEFAULT_EVENTS) | ve.CONTINUE | ve.MANAGER;
            return ve.isIn(event, events);
        };

        this.getResult = function() {
            return this.validationCache.result;
        };

        this.getError = function() {
            if (this.options.suppressError) {
                return '';
            }

            return $u('i18n').get(this.options.errorKey || this.defaultErrorKey);
        };

        this.reset = function() {
            this.validationCache = { value : null, result : vr.UNKNOWN };
        };

        this.initialize = function(o) {
            this.options = o;
            this.uid = o.uid || $u('uidGenerator').getUid();
            this.chain = o.chain;

            this.reset();
        };

    };

    juliet.registerModule('juliet.validation.validators', 'Base-0.2', BaseClass);

})();
